package com.wnn.demo.model.task.service.impl;//package org.springblade.system.user.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wnn.demo.domain.Accessory;
import com.wnn.demo.domain.Hospital;
import com.wnn.demo.domain.Task;
import com.wnn.demo.model.task.mapper.AccessoryFileMapper;
import com.wnn.demo.model.task.mapper.TaskMapper;
import com.wnn.demo.model.task.service.TaskService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@AllArgsConstructor
public class TaskServiceImpl implements TaskService {

	private TaskMapper taskMapper;

	private AccessoryFileMapper accessoryFileMapper;

	@Override
	public void save(Task task) {
		taskMapper.save(task);
	}

	@Override
	public void submit(Task task) {
		taskMapper.submit(task);
	}

	@Override
	public List<Task> findList() {
		return taskMapper.findList();
	}

	@Override
	public Task selectOne(Task task) {
		return taskMapper.selectOne(task);
	}

	@Override
	public Integer deletedOne(String id) {
		Integer one = taskMapper.deletedOne(id);
		return one;
	}

	@Override
	public void update(Task task) {
		taskMapper.update(task);
	}

	@Override
	public Integer submitId(Task task) {
		return taskMapper.submitId(task);
	}

	@Override
	public List<Task> findAuditList() {
		return taskMapper.findAuditList();
	}

	@Override
	public List<Task> findReleaseTask() {
		return taskMapper.findReleaseTask();
	}

	@Override
	public List<Task> selectByTime(Task task) {
		return taskMapper.selectByTime(task);
	}



	@Override
	public PageInfo<Task> selectTaskAll(Integer page, Integer limit) {
		PageHelper.startPage(page,limit);
		List<Task> info= taskMapper.findList();
		for (int i = 0; i < info.size(); i++) {
			List<Accessory> file = accessoryFileMapper.findFile(info.get(i).getId());
			for (Accessory accessory : file) {
				System.out.println(accessory.getId());
			}
			info.get(i).setAccessories(file);
		}
		return new PageInfo< >(info);
	}

}
